package chpt05;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class ArrayQeque {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		while(n<0||n>1000)
			n=in.nextInt();
		Integer[] No=new Integer[n];
		for (int i = 0; i < n; i++) {
			No[i]=new Integer(in.nextInt());
		}
		Queue<Integer> q1=new ArrayDeque<Integer>();
		Queue<Integer> q2=new ArrayDeque<Integer>();
		for (int i = 0; i < n; i++) {
			if(q1.size()==2){
				System.out.printf(q1.poll()+" "+q1.poll()+" ");
				if(q2.size()>=1)
					System.out.printf(q2.poll()+" ");
			}
			if(No[i]%2==1)
				q1.add(No[i]);
			else
				q2.add(No[i]);
		}
		while(q1.size()>1)
			System.out.printf(q1.poll()+" ");
		if(q1.size()==1)
			System.out.printf(q1.poll()+"");
		while(q2.size()>1)
			System.out.printf(q2.poll()+" ");
		if(q2.size()==1)
			System.out.printf(q2.poll()+"");
		in.close();
	}

}
